package com.pwt.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.pwt.entity.Menu;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Collection;

@Data
@Schema(description = "菜单树形模型")
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class MenuTreeModel {

    @Schema(name = "name",description = "菜单ID")
    private String id;

    @Schema(name = "name",description = "权限名称")
    private String name;

    @Schema(name = "level", description = "权限等级")
    private Integer level;

    @Schema(name = "path",description = "路由")
    private String path;

    @Schema(name = "parentId",description = "上级ID")
    private String parentId;

    @Schema(name = "icon",description = "图标")
    private String icon;

    @Schema(name = "sortNumber",description = "排序")
    private Integer sortNumber;

    @Schema(name = "permission",description = "权限标识")
    private String permission;

    @Schema(name = "checked",description = "是否选中")
    private boolean checked;

    @Schema(name = "children",description = "子节点")
    private Collection<MenuTreeModel> children;

    public MenuTreeModel(Menu menu) {
        this.id = menu.getId();
        this.name = menu.getName();
        this.level = menu.getLevel();
        this.path = menu.getPath();
        this.parentId = menu.getParentId();
        this.icon = menu.getIcon();
        this.sortNumber = menu.getSortNumber();
        this.permission = menu.getPermission();
        this.checked = menu.isChecked();
    }
}
